import 'package:enjoy_plus/providers/kuan_provider.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

class KuAnContent extends StatelessWidget {
  const KuAnContent({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('详情页'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Consumer<KuAnProvider>(
              builder: (context, kuanProvider, child) {
                return Text(
                  '当前选中: ${kuanProvider.navBarData[kuanProvider.currentNavIndex]}',
                  style: const TextStyle(fontSize: 20),
                );
              },
            ),
            ElevatedButton(
              onPressed: () {
                // 修改选中项
                context.read<KuAnProvider>().setCurrentNavIndex(
                  (context.read<KuAnProvider>().currentNavIndex + 1) % 
                  context.read<KuAnProvider>().navBarData.length
                );
              },
              child: const Text('切换下一项'),
            ),
          ],
        ),
      ),
    );
  }
}
